


function [fwhm,x,y] = getfwhm(p)

% quick function to get FWHM of a linescan. This is written assuming the
% max is somewhere in the middle of p and there is only the central peak

%% split up plot into two segments
p1 = p(floor(length(p)/2):-1:1);
p2 = p((floor(length(p)/2)+1):length(p));

p1 = p1-min(p1);
p2 = p2-min(p2);

[max1,I1] = max(p1);
[max2,I2] = max(p2);

x1 = find(p1<(max1/2),1);
x1 = floor(length(p)/2)+1-x1;

x2 = find(p2<(max2/2),1);
x2 = floor(length(p)/2)+x2;
fwhm = x2-x1;
x = [x1,x2];
y = p(x);

